/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package project.jpdftools.other;

import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import javax.swing.JOptionPane;
import project.jpdftools.managers.LocalizationManager;

/**
 *
 * @author Mido
 */
public class JOpenFile {

    public static int showOptionDialog(String message, String title, Object[] options, String file_name_to_open) {
        if (JOptionPane.showOptionDialog(null, message, title, JOptionPane.YES_NO_OPTION, 1, null, options, options[0]) == 0) {
            File file = new File(file_name_to_open);

            // open the file if it exists
            if (file.exists() == true) {
                try {
                    // open the file
                    Desktop.getDesktop().open(file);
                } catch (IOException ex) {
                }
            } else {
                // file doesn't exist
                JOptionPane.showMessageDialog(null, LocalizationManager.getCurrent_resource().getString("FILE_NOT_FOUND"),
                        LocalizationManager.getCurrent_resource().getString("ERROR"), 0);
            }
        }
        return 0;
    }
}
